import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BrokerageUserVo, BrokerageUserForm, BrokerageUserQuery } from '@/api/brokerage/user/types';

/**
 * 查询分销员列表
 * @param query
 * @returns {*}
 */

export const listBrokerageUser = (query?: BrokerageUserQuery): AxiosPromise<BrokerageUserVo[]> => {
  return request({
    url: '/lawyer/brokerageUser/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分销员详细
 * @param brokerageUserId
 */
export const getBrokerageUser = (brokerageUserId: string | number): AxiosPromise<BrokerageUserVo> => {
  return request({
    url: '/lawyer/brokerageUser/' + brokerageUserId,
    method: 'get'
  });
};

/**
 * 新增分销员
 * @param data
 */
export const addBrokerageUser = (data: BrokerageUserForm) => {
  return request({
    url: '/lawyer/brokerageUser/saveBrokerageUser',
    method: 'post',
    data: data
  });
};

/**
 * 修改分销员
 * @param data
 */
export const updateBrokerageUser = (data: BrokerageUserForm) => {
  return request({
    url: '/lawyer/brokerageUser/updateBrokerageUser',
    method: 'post',
    data: data
  });
};

/**
 * 删除分销员
 * @param brokerageUserId
 */
export const delBrokerageUser = (brokerageUserId: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/brokerageUser/removeBrokerageUser/' + brokerageUserId,
    method: 'delete'
  });
};

export const activeBrokerageUser = (brokerageUserId: string | number) => {
  const data = {
    brokerageUserId
  };
  return request({
    url: '/lawyer/brokerageUser/activeBrokerageUser',
    method: 'post',
    data: data
  });
};

export const inactiveBrokerageUser = (brokerageUserId: string | number) => {
  const data = {
    brokerageUserId
  };
  return request({
    url: '/lawyer/brokerageUser/inactiveBrokerageUser',
    method: 'post',
    data: data
  });
};

export const commissionSettlement = (brokerageRecordId: string | number) => {
  const data = {
    brokerageRecordId
  };
  return request({
    url: '/lawyer/brokerageUser/commissionSettlement',
    method: 'post',
    data: data
  });
};
